<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
	<!-- jQuery (需要引入 jQuery) -->
	<script src="<%=path %>/static/jquery.min.js" ></script>

<script type="text/javascript">
function add(){
// 	alert("add1");
	$.post( 
		"<%=path%>/ajax2", 
		$("#ahform").serialize(),
		function(data,status){
// 			if(data){
// 				alert('成功');
// 			}else{
				
// 			}
			alert(data);
			alert(data.msg);
			alert(status);
		}
	);
}
function add2()
{
//     alert($('#ahform').serialize());
	$.ajax({
	    type: "POST",
	    dataType: "json",
	    async: false,
// 	    accepts: "*/*",
	    url: "<%=path%>/ajax2",
        data: $('#ahform').serialize(),
        success : function (data, textStatus) {
//         	var jsonData = JSON.parse(data);
//         	alert(jsonData);
//         	alert(textStatus);
            alert("成功："+data);
            alert("成功："+data.msg);
            alert("成功："+textStatus);
// 			alert("添加成功！");
			//location.href="<%=path%>/zkStuden/list";
	    },
	    error: function(data) {
			alert("失败："+data.responseText);
			//location.href="<%=path%>/zkStuden/list";
		}
	});
}
function add3(){
	alert("add3");
	$.load( 
		"<%=path%>/ajax1", 
		$("#ahform").serialize(),
		function(responseTxt,statusTxt,xhr){
			alert(responseTxt);
			alert(statusTxt);
			alert(xhr );
			location.href="<%=path%>/zkStuden/list";
		}
	);
}
</script>
	
</head>
<body>
<form id="ahform" action="<%=path%>/ajax1" method="post" class="form-horizontal">
<br>学生姓名： <input type="text" name="student_id" value="">
<br>爱好： 
	<select name="ah_id">
		<option value="1">游泳</option>
		<option value="2">篮球</option>
		<option value="3">读书</option>
		<option value="4">看报</option>
	</select>
<!-- 	<input> -->
<br><input type="button" value="提交1" onclick="add();">
<br><input type="button" value="提交2" onclick="add2();">
<br><input type="button" value="提交3" onclick="add3();">
</form>

</body>
</html>